<?php

class Plyte_Plyte {
	
	public static $base_url = '/';

	public static function defaultRouteCallback(&$request) {
		try {
			$class = new ReflectionClass($request->param('controller').'_Controller');

			$controller = $class->newInstance();

			$class->getMethod('before')->invoke($controller);
			$class->getMethod($request->param('action').'Action')->invokeArgs($controller, array($request));
			$class->getMethod('after')->invoke($controller);
		} catch (Exception $e) {
			if ($e instanceof ReflectionException) {
				// Class/Method did not exist
				throw new Exception("Controller/Action not found");
			}
		}
	}

}